(function($) {
	$.fn.PavOffCavasmenu = function(opts) {
	 	
		// initialize every element
		this.each(function() {  
			var $btn = $('#mainnav .btn-navbar');
			var	$nav = null;
			 
			var off_nav = '<div id="off-canvas-nav"><nav class="pavo-mainnav" ><div id="off-canvas-button"><span class="icon-remove-sign"></span></div></nav></div>';
			$(off_nav).appendTo(document.body);

	 	 	var $menucontent = $($btn.data('target')).find('.megamenu').clone();
	  

	 	 	$menucontent.appendTo('#off-canvas-nav .pavo-mainnav');

 			$('html').addClass ('off-canvas');
			$("#off-canvas-button").click( function(){
				$btn.click();	
			} ); 
			$btn.toggle( function(){
				$("body").addClass('off-canvas-active').removeClass("off-canvas-inactive");
			}, function(){
				$("body").removeClass('off-canvas-active').addClass("off-canvas-inactive");
			} );

		});
		return this;
	};
	
})(jQuery);


$(window).ready( function(){
	/*  Fix First Click Menu */
	$(document.body).on('click', '#mainnav [data-toggle="dropdown"]' ,function(){
		if(!$(this).parent().hasClass('open') && this.href && this.href != '#'){
			window.location.href = this.href;
		}

	});

	$("#mainnav").PavOffCavasmenu();

	$(".quantity-adder .add-action").click( function(){
		if( $(this).hasClass('add-up') ) {  
			$("[name=quantity]",'.quantity-adder').val( parseInt($("[name=quantity]",'.quantity-adder').val()) + 1 );
		}else {
			if( parseInt($("[name=quantity]",'.quantity-adder').val())  > 1 ) {
				$("input",'.quantity-adder').val( parseInt($("[name=quantity]",'.quantity-adder').val()) - 1 );
			}
		}
	} );

} );